package com.xuxu.blog.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.xuxu.blog.entity.DictEntity;
import com.xuxu.blog.service.DictService;
import com.xuxu.common.utils.PageUtils;
import com.xuxu.common.utils.R;



/**
 * 
 *
 * @author maxuxu
 * @email maxuxu019@gmail.com
 * @date 2022-08-21 22:22:32
 */
@RestController
@RequestMapping("blog/dict")
public class DictController {
    @Autowired
    private DictService dictService;

    /**
     * 列表
     */
    @RequestMapping("/list")
            public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dictService.queryPage(params);

        return R.ok().put("page", page);
    }

    @RequestMapping("/findAll")
    public R findAll() {
        return dictService.findAll();
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {

        DictEntity dict = dictService.getById(id);

        return R.ok().put("dict", dict);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
            public R save(@RequestBody DictEntity dict){
		dictService.save(dict);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
            public R update(@RequestBody DictEntity dict){
		dictService.updateById(dict);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
            public R delete(@RequestBody Integer[] ids){
		dictService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
